home *** CD-ROM | disk | FTP | other *** search
- ;filename HICOPY.ASM - file to test copying of a block of
- ; data into the HMA from conventional memory
- ;Released into the Public Domain - November/88 by D. Roy
-
- CODE SEGMENT PARA PUBLIC 'CODE'
- ASSUME CS:CODE, DS:CODE ;-----------------------------;
- ORG 100H ;COM file format! Remember to ;
- ; use EXE2BIN ;
- START: ;-----------------------------;
- JMP XMSTEST
- ;data area
- COPY_CODE LABEL BYTE
- SOURCE_DATA DB 16 DUP ("DATA ")
- COPY_END LABEL BYTE
- XMSControl DD ?
-
- NODRIVER_MSG DB 'No XMS driver installed!...$'
- BADVERS_MSG DB 'Requires Version 2.X XMS Driver!...$'
- NOHMA_MSG DB 'HMA denied!...$'
- OKHMA_MSG DB 'HMA successfully allocated!',10,13,'$'
- NOA20_MSG DB 'A20 Line not enabled!$'
- A20LINE_MSG DB 'A20 Line enabled...',10,13,'$'
- COPY_MSG DB 'Copying...$'
- COMPLETE_MSG DB 'complete.',10,13,'$'
-
- ;code area
- XMSTEST:
- MOV AX,4300h
- INT 2Fh
- CMP AL,80h
- LEA DX,NODRIVER_MSG
- JNE ERROR_EXIT
- ;get address of control driver function
- MOV AX,4310h
- INT 2Fh
- MOV WORD PTR [XMSControl],BX
- MOV WORD PTR [XMSControl+2],ES
- ;get driver's version number
- MOV AH,00
- CALL [XMSControl]
- CMP AH,2
- LEA DX,BADVERS_MSG
- JNE ERROR_EXIT
- ;now request an HMA
- MOV AH,01
- MOV DX,80 ;16X5 bytes
- CALL [XMSControl]
- ;and verify allocation
- OR AX,AX
- LEA DX,NOHMA_MSG
- JE ERROR_EXIT
- LEA DX,OKHMA_MSG
- CALL WRITE_STRING
- ;now, enable the A20 address line
- MOV AH,3
- CALL [XMSControl]
- OR AX,AX
- LEA DX,NOA20_MSG
- JE ERROR_EXIT
- LEA DX,A20LINE_MSG
- CALL WRITE_STRING
- ;OK, let's do a block copy to the HMA
- LEA DX,COPY_MSG ;say what we're up to
- CALL WRITE_STRING
- CLD ;direction forward
- PUSH SI ;save what we're using
- PUSH DI
- PUSH ES
- MOV CX,OFFSET COPY_END ;end of data
- SUB CX,OFFSET COPY_CODE ;start of data
- SHR CX,1 ;divide by 2 for words
- LEA SI,COPY_CODE ;point to source
- MOV BX,0FFFFh ;segment of HMA
- MOV ES,BX ; into ES
- MOV DI,0010h ;point to offset
- L1: MOVSW ;moving words is faster
- LOOP L1 ;loop until done
- POP ES ;housecleaning
- POP DI
- POP SI
- ;and signal completion
- LEA DX,COMPLETE_MSG
- CALL WRITE_STRING
- ;---------------------------------------------------------------------------
- ;The next four instructions reflect good housekeeping that any application
- ; should do on exiting. However, if we do this in this test program, you
- ; won't be able to use DEBUG to see the evidence of the successful block
- ; copy into the HMA. After checking the HMA with DEBUG, run the program
- ; HMACLEAR.COM to release our handiwork.
- ;
- ; DEBUG Instructions:
- ; 1) Run DEBUG
- ; 2) At the - prompt, type
- ; D FFFF:0010
- ; and press <enter>
- ; 3) Type Q <enter> to return to DOS.
- ;--------------------------------------------------------------------------
- ;finally, disable the A20 address line
- ; MOV AH,4
- ; CALL [XMSControl]
- ;and release the HMA
- ; MOV AH,2
- ; CALL [XMSControl]
- JMP EXIT
- ERROR_EXIT:
- CALL WRITE_STRING
- EXIT: INT 20h
-
- ;-- subroutines ---------------
-
- WRITE_STRING PROC NEAR
- MOV AH,9
- INT 21h
- RET
- WRITE_STRING ENDP
-
- CODE ENDS
- END START